package com.symaster.backups.frame.element.table;

import lombok.Getter;

import javax.swing.*;
import java.awt.*;

/**
 * @author yinmiao
 * @version 2024/2/5
 */
public class TableLayoutItem implements LayoutManager {

    @Getter
    private final JComponent component;
    private final Dimension minimumLayoutSize = new Dimension(1, 1);

    public TableLayoutItem(JComponent component) {
        this.component = component;
    }

    @Override
    public void addLayoutComponent(String name, Component comp) {

    }

    @Override
    public void removeLayoutComponent(Component comp) {

    }

    @Override
    public Dimension preferredLayoutSize(Container parent) {
        return null;
    }

    @Override
    public Dimension minimumLayoutSize(Container parent) {
        return minimumLayoutSize;
    }

    @Override
    public void layoutContainer(Container parent) {

    }

    public int getColumnPreferredWidth(int index) {
        if (component.getComponentCount() > index) {
            return component.getComponent(index).getPreferredSize().width;
        }
        return -1;
    }
}
